import app
import requests


class StaffAPI:
    def __init__(self):
        self.url_staff = app.path + "/api/sys/user?page=1&size=10"
        self.url_staff_add = app.path + "/api/sys/user"
        self.url_staff_other = app.path + "/api/sys/user/{}"

    def get_staff(self, token):
        return requests.get(self.url_staff, headers={"Authorization": token})

    # 员工添加
    def staff_add(self, token, data):
        return requests.post(self.url_staff_add, headers={"Authorization": token}, json=data)

    # 员工修改
    def staff_modify(self, staff_id, token, data):
        return requests.put(self.url_staff_other.format(staff_id), headers={"Authorization": token}, json=data)

    # 员工查询
    def staff_inquiry(self, staff_id, token):
        return requests.get(self.url_staff_other.format(staff_id), headers={"Authorization": token})

    # 员工删除
    def staff_delete(self, token, staff_id):
        return requests.delete(self.url_staff_other.format(staff_id), headers={"Authorization": token})
